package JasPerl::Response;

use strict;
use warnings;

use JasPerl::Util::Exceptions;
use JasPerl::Util::Locale;

use IO::Handle;

use constant {
    SC_ACCEPTED 	               => 202,
    SC_BAD_GATEWAY 	               => 502,
    SC_BAD_REQUEST 	               => 400,
    SC_CONFLICT 	               => 409,
    SC_CONTINUE                        => 100,
    SC_CREATED                         => 201,
    SC_EXPECTATION_FAILED              => 417,
    SC_FORBIDDEN                       => 403,
    SC_FOUND                           => 302,
    SC_GATEWAY_TIMEOUT                 => 504,
    SC_GONE                            => 410,
    SC_HTTP_VERSION_NOT_SUPPORTED      => 505,
    SC_INTERNAL_SERVER_ERROR           => 500,
    SC_LENGTH_REQUIRED                 => 411,
    SC_METHOD_NOT_ALLOWED              => 405,
    SC_MOVED_PERMANENTLY               => 301,
    SC_MOVED_TEMPORARILY               => 302,
    SC_MULTIPLE_CHOICES                => 300,
    SC_NO_CONTENT                      => 204,
    SC_NON_AUTHORITATIVE_INFORMATION   => 203,
    SC_NOT_ACCEPTABLE                  => 406,
    SC_NOT_FOUND                       => 404,
    SC_NOT_IMPLEMENTED                 => 501,
    SC_NOT_MODIFIED                    => 304,
    SC_OK                              => 200,
    SC_PARTIAL_CONTENT                 => 206,
    SC_PAYMENT_REQUIRED                => 402,
    SC_PRECONDITION_FAILED             => 412,
    SC_PROXY_AUTHENTICATION_REQUIRED   => 407,
    SC_REQUEST_ENTITY_TOO_LARGE        => 413,
    SC_REQUEST_TIMEOUT                 => 408,
    SC_REQUEST_URI_TOO_LONG            => 414,
    SC_REQUESTED_RANGE_NOT_SATISFIABLE => 416,
    SC_RESET_CONTENT                   => 205,
    SC_SEE_OTHER                       => 303,
    SC_SERVICE_UNAVAILABLE             => 503,
    SC_SWITCHING_PROTOCOLS             => 101,
    SC_TEMPORARY_REDIRECT              => 307,
    SC_UNAUTHORIZED                    => 401,
    SC_UNSUPPORTED_MEDIA_TYPE          => 415,
    SC_USE_PROXY                       => 305
};


# buffering

sub is_committed {
}

sub reset {
}

sub reset_buffer {
}

sub flush_buffer {
}

# response status

sub set_status {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

sub send_redirect {
    # FIXME: set_status, headers
}

sub send_error {
    # FIXME: set_status, headers
}

# response headers

sub contains_header {
    # defaults to false
}

sub set_header {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

sub add_header {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

# response content

sub get_character_encoding {
    return 'ISO-8859-1';
}

sub set_character_encoding {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

sub get_content_type {
    # default implementation returns null
}

sub set_content_type {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

sub set_content_length {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

sub get_writer {
    return IO::Handle->new();
}

# internationalization

sub get_locale {
    return JasPerl::Util::Locale->get_default();
}

sub set_locale {
    # JasPerl::Util::UnsupportedOperationException->throw();
}

# cookies

sub add_cookie {
}

# session tracking

sub encode_url {
    return $_[1];
}

sub encode_redirect_url {
    return $_[0]->encode_url($_[1]);
}

1;
